package com.itheima.domain;


import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;

public class User {

    private Integer id; //编号，唯一
    @NotNull(message = "用户名不能为空")
    @Length(min = 3,max = 8,message = "用户名只能是3到8位数")
    private String username; //用户名
    @NotNull(message = "密码不能为空")
    @Length(min = 3,max = 20,message = "密码只能是3到20位数")
    private String password; //密码
    @NotNull(message = "昵称不能为空")
    private String realname; //真实姓名
    @NotNull(message = "性别不能为空")
    @Length(min = 1,max = 1,message = "性别只能是男或者女")
    private String gender; //性别
    @JsonFormat(pattern = "yyyy-MM-dd")  //给响应用的
    @DateTimeFormat(pattern = "yyyy-MM-dd")  //给请求用
    @NotNull(message = "生日不能为空")
    private String birthday; //生日

    public User() {
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", realname='" + realname + '\'' +
                ", gender='" + gender + '\'' +
                ", birthday='" + birthday + '\'' +
                '}';
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public User(Integer id, String username, String password, String realname, String gender, String birthday) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.realname = realname;
        this.gender = gender;
        this.birthday = birthday;
    }
}
